﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CDB.LinqModel.Data;
using CDB.LinqData;
using CDB.LinqModel;

public partial class ArchitectDetail : System.Web.UI.Page
{
    #region Variable Declration
    IDataRepository _dataObject = new DataRepository();
    ArchitecturalWork aWork;
    Architect architect;
    List<ArchitecturalWork> aWorks = new List<ArchitecturalWork>();
    #endregion

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            if (Request.QueryString["Id"] != null)
            {
                fillBanners(Convert.ToInt32(Request.QueryString["Id"].ToString()));
                fillArchitectDetail(Convert.ToInt32(Request.QueryString["Id"].ToString()));
                fillProjectDetail(Convert.ToInt32(Request.QueryString["Id"].ToString()));
            }

        }
    }
    private void fillBanners(int architectId)
    {
        aWork = new ArchitecturalWork(_dataObject);
        aWork.ArchitectId = architectId;
        aWorks = aWork.GetAllWorksByArchitectId();

        if (aWorks != null)
        {
            for (int i = 0; i < aWorks.Count; i++)
            {
                topbanners.InnerHtml += "<li><div class=\"bannerImage\"><img style='width:930px !important; height:303px !important;' src='architecturalWorks/" + architectId.ToString() + "/" + aWorks[i].ProjectImage + "' /></div></li>";
            }
        }
    }
    private void fillArchitectDetail(int architectId)
    {
        architect = new Architect(_dataObject);
        architect.Id = architectId;
        architect.GetArchitectById();

        if (architect.Id != 0)
        {
            heading.InnerHtml = architect.Firm;
            dvDescription.InnerHtml = "<strong>Description:</strong><br />" + architect.DescriptionLine;
            dvRightPanel.InnerHtml = "<strong>Address:</strong><br />" + architect.AddressLine + "<br /><strong>Phone: </strong>" + architect.Phone + " <br /><strong>Fax: </strong>" + architect.Fax + "<br />" + architect.Email + "<br /><a href='http://" + architect.Website + "' target='_blank'>" + architect.Website + "</a><hr /><strong>No. Of Employees:</strong><br />" + architect.NoOfEmployees + "<hr /><strong>Founded:</strong><br />" + architect.FoundedYear + "<hr /><strong>Specialization:</strong><br />" + architect.Specialization + "<hr />";
        }
    }
    private void fillProjectDetail(int architectId)
    {
        aWork = new ArchitecturalWork(_dataObject);
        aWork.ArchitectId = architectId;
        aWorks = aWork.GetAllWorksByArchitectId();

        if (aWorks.Count > 0)
        {
            for (int i = 0; i < aWorks.Count; i++)
            {
                projectLine.InnerHtml += "<div style='float:left;width:150px;'><img src='architecturalWorks/" + aWorks[i].ArchitectId.ToString() + "/" + aWorks[i].ProjectImage + "'></a></div>";
                projectLine.InnerHtml += "<div style='float:left; margin-left:20px;width: 730px;'>" + aWorks[i].DescriptionLine + "</div> <div style='clear:both;'></div><hr />";
            }
        }
    }
}